package com.hn.gege.sys.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hn.gege.sys.modules.sys.entity.Role;
import com.hn.gege.sys.modules.sys.mapper.RoleMapper;
import com.hn.gege.sys.modules.sys.service.IRoleService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author zxy
 * @since 2020-08-07
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Override
    public Role getByPk(String code) {
        LambdaQueryWrapper<Role> lambda = new QueryWrapper<Role>().lambda()
                .eq(Role::getCode, code);
        return baseMapper.selectOne(lambda);
    }

    @Override
    public boolean updateByPk(Role role) {
        LambdaQueryWrapper<Role> lambda = new QueryWrapper<Role>().lambda()
                .eq(Role::getCode, role.getCode());
        return super.update(role, lambda);
    }

    @Override
    public boolean removeByPk(String code) {
        LambdaQueryWrapper<Role> lambda = new QueryWrapper<Role>().lambda()
                .eq(Role::getCode, code);
        return super.remove(lambda);
    }

}
